import { useModel } from "umi";

import AddStaff from "../components/staff/Add";
import CreateStaff from "../components/staff/Create";
import EditStaff from "../components/staff/Edit";
import EditSystemStaff from "../components/staff/EditSystem";
import ChangeMemberOfStaff from "../components/staff/ChangeMember";
import BindingMemberOfStaff from "../components/staff/BindingMember";

const useHelperStaff = () => {
    const { setModalVisible, setModalTitle, setModalWidth, setModalComponent } = useModel("global.modal");

    const openAddStaffModal = ({ reloadData, staffs }) => {
        setModalTitle("添加人员");
        setModalVisible(true);
        setModalWidth(500);
        setModalComponent(<AddStaff reloadData={reloadData} staffs={staffs} />);
    };

    const openCreateStaffModal = ({ reloadData }) => {
        setModalTitle("新建员工信息");
        setModalVisible(true);
        setModalWidth(500);
        setModalComponent(<CreateStaff reloadData={reloadData} />);
    };

    const openEditStaffModal = ({ staff, reloadData }) => {
        setModalTitle("编辑员工信息");
        setModalVisible(true);
        setModalWidth(500);
        setModalComponent(<EditStaff staff={staff} reloadData={reloadData} />);
    };

    const openEditSystemStaffModal = ({ staff, reloadData }) => {
        setModalTitle("编辑系统员工信息");
        setModalVisible(true);
        setModalWidth(500);
        setModalComponent(<EditSystemStaff staff={staff} reloadData={reloadData} />);
    };

    const openChangeMemberOfStaffModal = ({ staff, reloadData }) => {
        setModalTitle("员工变更绑定的成员(外部)信息");
        setModalVisible(true);
        setModalWidth(500);
        setModalComponent(<ChangeMemberOfStaff staff={staff} reloadData={reloadData} />);
    };

    const openBindingMemberOfStaffModal = ({ staff, reloadData }) => {
        setModalTitle("员工绑定成员(外部)信息");
        setModalVisible(true);
        setModalWidth(500);
        setModalComponent(<BindingMemberOfStaff staff={staff} reloadData={reloadData} />);
    };

    return { openAddStaffModal, openCreateStaffModal, openEditStaffModal, openEditSystemStaffModal, openChangeMemberOfStaffModal, openBindingMemberOfStaffModal };
};

export default useHelperStaff;
